package cn.tmpan.project.controller;

import cn.tmpan.project.common.ServerResponse;
import cn.tmpan.project.service.INfzhService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author AutoGenerator
 */
@Api(tags = {"Nfzh"}, description = "模块")
@RestController
@RequestMapping(value = "/nfzh")
public class NfzhRestController {

    @Autowired
    private INfzhService nfzhService;

    @ApiImplicitParams({
            @ApiImplicitParam(value = "用户名", name = "hzxm", required = true),
            @ApiImplicitParam(value = "身份证号", name = "sfzhm",required = true)
    })
    @ApiOperation(value = "查询用户", response = ServerResponse.class)
    @GetMapping(value = "/select/by/login")
    public ServerResponse selectByLogin(String hzxm, String sfzhm) {
        try {
            return ServerResponse.createBySuccess(this.nfzhService.selectNfzhForLogin(hzxm, sfzhm));
        } catch (Exception e) {
            return ServerResponse.createByErrorMessage(e.getMessage());
        }
    }

    @ApiImplicitParam(value = "图片名", name = "picName",required = true)
    @ApiOperation(value = "图片展示", response = ServerResponse.class)
    @GetMapping(value = "/image/{picName}/preview")
    public byte[] bgImage(@PathVariable("picName") String picName) {
        try{
            return this.nfzhService.bgImage(picName);
        }catch (Exception e){
         return null;
        }
    }

    @ApiImplicitParams({
            @ApiImplicitParam(value = "身份证号", name = "sfzhm", required = true),
            @ApiImplicitParam(value = "公示信息是否准确", name = "gsxyzq", required = true),
            @ApiImplicitParam(value = "户籍信息是否准确", name = "hjxxzq", required = true),
            @ApiImplicitParam(value = "宗地图有误", name = "zdtyw", required = true),
            @ApiImplicitParam(value = "户产分地图有误", name = "hcfdtyw",required = true)
    })
    @ApiOperation(value = "意见反馈", response = ServerResponse.class)
    @GetMapping(value = "/feedBack")
    public ServerResponse feedBack(String sfzhm, int gsxyzq, int hjxxzq, int zdtyw, int hcfdtyw) {
        try {
            return ServerResponse.createBySuccess(this.nfzhService.feedBack(sfzhm, gsxyzq, hjxxzq, zdtyw, hcfdtyw));
        } catch (Exception e) {
            return ServerResponse.createByErrorMessage(e.getMessage());
        }
    }

}
